﻿using SketchUpAPI.NET.Enums;
using SketchUpAPI.NET.SketchUp.Exception;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace SketchUpAPI.NET.Objects
{
    public class Style : Entity
    {
        #region API 函数
        /// <summary>
        /// 获取样式的名字
        /// </summary>
        /// <param name="style"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        [DllImport(LIB)]
        static extern SUResult SUStyleGetName(IntPtr style, ref IntPtr name);

        /// <summary>
        /// 设置样式名称
        /// </summary>
        /// <param name="style"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        [DllImport(LIB)]
        static extern SUResult SUStyleSetName(IntPtr style, [MarshalAs(UnmanagedType.LPUTF8Str)] string name);
        #endregion

        /// <summary>
        /// 样式名字
        /// </summary>
        public string Name
        {
            get
            {
                StringRef s = StringRef.Empty;
                SketchUpExceptionHelper.ThrowSUResult(SUStyleGetName(Id, ref s.Id));
                return s.Dispose();
            }
            set
            {
                SketchUpExceptionHelper.ThrowSUResult(SUStyleSetName(Id, value));
            }
        }

        internal Style(IntPtr id) => Id = id;
    }
}